package com.cwl.base.day04.file;

import java.io.File;

/**
 * @program: java_base
 * @description:
 * @author: ChenWenLong
 * @create: 2019-11-08 13:55
 **/
public class FileTree {
    public static void main(String[] args) {
        //找一个自己硬盘上有用的文件夹
        File f = new File("d:/aaa");
        printFile(f, 0);
    }

    static void printFile(File file,int level){
        for (int i = 0; i < level; i++) {
            System.out.print("-");
        }
        System.out.println(file.getName());

        if(file.isDirectory()){
            File[]  files = file.listFiles();
            for (File temp : files) {
                printFile(temp, level+1);
            }
        }
    }
}
